<!-- 平台内考级详情 -->
<template>
	<view class="container">
		<view class="c-rich">
			<view class="rich-content">
				<mp-html :content="testInfo.content" />
			</view>
			<view class="rich-btn">
				<view @click="toTestSignUp" v-if="testInfo.show_status==1">
					<text>前往报名</text>
				</view>
				<view v-else>
					<text>暂停报名</text>
				</view>
			</view>
		</view>
		<view class="c-overlay">
			<StatusOverlay v-if="isOverlay" @click.native="isOverlay=false"></StatusOverlay>
		</view>
	</view>
</template>

<script>
	import StatusOverlay from "@/pages/components/StatusOverlay.vue"
	export default {
		name:"testDetail",
		components:{
			StatusOverlay
		},
		data() {
			return {
				// 用户身份
				status:this.$store.state.status,
				// 考级id
				testId:null,
				// 考级信息
				testInfo:{},
				// 身份认证
				isOverlay:false
			}
		},
		onLoad(query){
			this.testId = query.id
			this.getTestDetail(query.id)
		},
		onShareAppMessage() {
			return {
				title: this.testInfo.name,
				path: '/pages/pages_test/testOtherDetail?id'+this.testId
			}
		},
		onShareTimeline() {},
		methods: {
			// 获取考级详情
			getTestDetail(id){
				this.$http.getTestDetail({id}).then(res=>{
					this.testInfo = res
				})
			},
			// 跳转报名
			toTestSignUp(){
				let type = uni.getStorageSync("userInfo").identityData
				if(!type){
					this.getUserInfo()
				}
				if(!this.$store.state.token){
					this.toLogin()
				}else if(!this.status || this.status == 'user'){
					this.isOverlay=true
				}else if((this.status == 'teacher' || this.status == 'org') && !type ){
					uni.$u.toast("您的身份认证申请正在审核中...")
				}else{
					this.navigateTo("testSignUp?id="+this.testId)
				}
				
			}
			
		}
	}
</script>

<style scoped lang="scss">
	.container{
		.c-rich{
			width: 100%;
			.rich-content{
				::v-deep img{
					width: 100% !important;
				}
			}
			.rich-btn {
				width: 100%;
				height: 100rpx;
				padding: 20rpx 0;
				position: fixed;
				bottom: 0;
				left: 0;
				background-color: #fff;
			
				&>view {
					// width: 160rpx;
					// height: 60rpx;
					width: 100%;
					font-size: 38rpx;
					font-weight: bold;
					color: #4093ec;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}
</style>
